# -*- coding: utf8 -*-
from human import Player,Enemy,Hunter,Warrior,Priest,Factory
from tmap import Map
from skill import Skill
from item import Item
from equipment import Equipment
import unittest

class BtTest_vol3(unittest.TestCase):
    def test_bt(self):
        lra = Factory.new(Hunter,mhp=100,hp=100,atk=100,defend=50,side="a") 
        zsa = Factory.new(Warrior,mhp=200,hp=200,atk=80,defend=80,side="a")
        msa = Factory.new(Priest,mhp=80,hp=80,atk=30,defend=60,side="a")
            #第1阵营3个人,猎人,战士,牧师   阵营：a
        lrb = Factory.new(Hunter,mhp=100,hp=100,atk=100,defend=50,side="b") 
        zsb = Factory.new(Warrior,mhp=200,hp=200,atk=80,defend=80,side="b")
            #第2阵营2个人,战士,猎人        阵营：b
        zsc = Factory.new(Warrior,mhp=200,hp=200,atk=80,defend=80,side="c")
        msc = Factory.new(Priest,mhp=90,hp=50,atk=30,defend=60,side="c")
            #第3阵营2个人 ,战士,牧师       阵营：c
        testmap = Map([[lra,zsa,0,0,0,0,0,0,0],   #地图   8*8  阵营3个
                      [msa,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,zsb],
                      [0,0,0,0,0,0,0,lrb],
                      [0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0],
                      [0,0,zsc,msc,0,0,0,0]])
        gongA = Equipment(atk=20,defend=20,name = "弓")  #武器
        gongB = Equipment(atk=30,defend=10,name = "弩",lv=20)
        fuziA = Equipment(atk=40,defend=0,name = "钢斧")
        fuziB = Equipment(atk=30,defend=20,name = "铁斧")
        itemHp = Item(hp=50)
        testmap.missionStart()              #游戏开始 
        testmap.mapRoundStart(flug="a")     #A阵营开始行动
        testmap.mapRoundStart(flug="b")     #B阵营开始行动
        testmap.mapRoundStart(flug="c")     #C阵营开始行动
        self.assertEqual(testmap.fly(lra,0,1),False)    #测试移动部分(包括出界,移动范围超限制)
        self.assertEqual(testmap.fly(lra,-1,0),False)
        self.assertEqual(testmap.fly(lra,-1,-1),False)
        self.assertEqual(testmap.fly(zsa,3,3),False)
        self.assertEqual(testmap.fly(msa,1,-1),False)
        self.assertEqual(testmap.fly(lrb,3,9),False)
        self.assertEqual(testmap.fly(zsc,8,2),False)
        self.assertEqual(testmap.fly(lra,2,0),True)
        self.assertEqual(testmap.fly(msa,3,0),True)
        self.assertEqual(testmap.fly(zsa,2,1),True)
        self.assertEqual(testmap.fly(zsb,2,5),True)
        self.assertEqual(testmap.fly(lrb,3,5),True)
        self.assertEqual(testmap.fly(zsc,5,2),True)
        self.assertEqual(testmap.fly(msc,5,3),True)
        self.assertEqual(testmap.getPosition(lra),(2,0))         #测试坐标方法
        # 当前地图位置
        #[0,0,0,0,0,0,0,0]
        #[0,0,0,0,0,0,0,0]
        #[lra,zsa,0,0,0,zsb,0,0]
        #[msa,0,0,0,0,lrb,0,0]
        #[0,0,0,0,0,0,0,0]
        #[0,0,zsc,msc,0,0,0,0]
        #[0,0,0,0,0,0,0,0]
        #[0,0,0,0,0,0,0,0]
        # 第1回合测试结束
        testmap.mapRoundStart(flug="a")     #第2回合开始
        testmap.mapRoundStart(flug="b")     
        testmap.mapRoundStart(flug="c")
        self.assertEqual(msc.hp,50)         #总血量与最大血量
        self.assertEqual(msc.mhp,90)
        self.assertEqual(msc.useItem(itemHp),True)   #测试道具使用，USE方法
        self.assertEqual(msc.hp==90,True)            #测试道具使用效果，HP增加
        self.assertEqual(msc.mhp==90,True)           #测试道具效果，不能超过最大HP
        self.assertEqual(lra.equip(gongB),False)     #测试武器限制
        self.assertEqual(lra.newAtk,100)
        self.assertEqual(lra.newDefend,50)
        self.assertEqual(lra.equip(gongA),True)      #测试装备后的属性
        self.assertEqual(lra.newAtk,120)
        self.assertEqual(lra.newDefend,70)
        self.assertEqual(lrb.equip(gongA),False)     #测试武器不能同时装在两个人身上
        self.assertEqual(lra.leftEquip(gongB),False) #测试没装在身上的东西，不能执行拿下命令
        self.assertEqual(lra.leftEquip(gongA),True)  #测试可移除的装备
        self.assertEqual(lra.newAtk,100)                #测试移除装备后的人物属性
        self.assertEqual(lra.newDefend,50)
        self.assertEqual(lrb.equip(gongA),True)      #装备被拆卸后，可装备在其他人身上
     
        
        
        
        
        
        
    
        
        
if __name__ == '__main__':
    unittest.main()
        
        
